<script type="text/javascript" src="/statics/js/ajaxupload.js"></script>
<script src="/statics/js/layer.js"></script>
<!-- 头部开始 -->
<div class="header">
    <!--    <div class="header_r"><img src="img/tx.jpg" width="30"></div>-->
    <div class="header_l"><a href="javascript:history.back(-1);"></a></div>
    <div class="header_m">完善资料</div>
</div>
<!-- 头部结束 -->
<div id="container"></div>
<!--协议开始-->
<form method="post" action="/saler/edit" id="formId"><div class="wanshan">
    <ul>
        <li style="margin:0 0 10px 0"><a class="up-pic-i"><input type="file" class="up-pic" id="identity" name="identity">上传图片</a></li>
        <li class="up-text">请上传手持身份证照片</li>
        <li class="up-pic-demo"></li>
        <li><input type="text" class="wanshan-text" placeholder="姓名" name="cust_realname" /></li>
        <li><input type="text" class="wanshan-text" placeholder="手机" name="cust_mobile" /></li>
        <li><input type="text" class="wanshan-text" placeholder="身份证" name="cust_identity" /></li>
        <input type="hidden" id="identity-img" name="identity_img" />
        <input type="hidden" value="1" name="dosubmit" />
    </ul>
</div>
</form>
<div class="pay-ok"><button id="btnid">提交</button></div>
<!--协议结束-->
<script type="text/javascript">
    $(function(){
		$('#btnid').click(function(){
				if(!$('input[name="cust_realname"]').val()){
					layer.msg('姓名 不能为空', {icon: 0});
					return false;
				}else if(!$('input[name="cust_mobile"]').val()){
					layer.msg('手机 不能为空', {icon: 0});
					return false;
				}else if(!$('#identity-img').val()){
                    layer.msg('请先上传手持身份证照片',{icon: 0});
                    return false;
                }else{
					$('#formId').submit();
				}
			});
        $('.up-pic').change(function(){
            ajaxFileUpload();
        });
        function ajaxFileUpload(){
            $.ajaxFileUpload({
                url: '/saler/edit/ajax/1',
                type: 'post',
                secureuri: false,
                fileElementId: 'identity',
                dataType: 'json',
                success: function(data){
                    var obj = eval(data);
                    $('#identity-img').val(obj.data);
                    $('.up-pic-demo').css({
                        'background':'url(<?=transUrl("'+obj.data+'")?>) no-repeat center',
                        'background-size':'cover'
                    });
                },
                error: function(e){
                    alert(e);
                }
            });
        }
    });
</script>